package com.treehouse.gui.viewport;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

import com.treehouse.pornstar.Pornstar;
import com.treehouse.url.farmer.URLFarmer;
import com.treehouse.url.loader.TrailerLoader;

public class ViewPort extends JFrame {

	private static final long serialVersionUID = 2956911506102455048L;
	private JPanel pan;
	private JComboBox awl;
	private JButton load;
	private URLFarmer farmer;
	private TrailerLoader loader;

	public ViewPort(String title, URLFarmer farmer, final TrailerLoader loader,
			LinkedList<Pornstar> list) {
		super(title);
		this.farmer = farmer;
		this.loader = loader;
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(new Dimension(600, 400));
		this.pan = new JPanel();
		this.awl = new JComboBox();
		this.load = new JButton("Load");
		this.pan.setLayout(new BorderLayout());
		this.pan.add(this.awl, BorderLayout.CENTER);
		this.pan.add(this.load, BorderLayout.PAGE_END);
		this.add(pan);
		for (Pornstar p : list) {
			this.awl.addItem(p);
		}
		this.load.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				Pornstar p = (Pornstar) awl.getSelectedItem();
					loader.loadScenesForPornstar(p);
			}

		});
	}
}
